package com.raymond.entity.settlement;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.raymond.entity.commons.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * desc-结算单实体
 *
 * @author houmenghe
 * @date 2025/04/21 16:05
 **/
@Data
@ApiModel("结算单实体")
public class OrderSettlementEntity extends BaseEntity {

    @ApiModelProperty("结算单号")
    private String code;

    @ApiModelProperty("结算单名称")
    @NotBlank(message = "结算单名称不能为空")
    private String name;

    @ApiModelProperty("组织机构系统编号")
    @NotNull(message = "组织机构系统编号不能为空")
    private Long organizationSysNo;

    @ApiModelProperty("组织名称")
    private String organizationName;

    @ApiModelProperty("供应商系统编号")
    @NotNull(message = "供应商系统编号不能为空")
    private Long supplierSysNo;

    @ApiModelProperty("供应商系统名称")
    private String supplierName;

    @ApiModelProperty("合同系统编号")
    private Long contractSysNo;

    @ApiModelProperty("结算日期")
    @NotNull(message = "结算日期不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date settlementDate;

    @ApiModelProperty("结算金额")
    @NotNull(message = "结算金额不能为空")
    private BigDecimal amount;

    @ApiModelProperty("其他费用金额")
    private BigDecimal otherAmount;

    @ApiModelProperty("实际结算金额 = 结算金额 + 其他费用金额")
    private BigDecimal totalAmount;

    @ApiModelProperty("结算备注")
    @Length(max = 200, message = "结算备注最多200个字符")
    private String comment;

    @ApiModelProperty("审批类型 0=结算审批 1=作废审批 2=调差审批")
    private OrderSettlementAuditTypeEnum auditType;

    @ApiModelProperty("审批状态 0=不需要审批 1=审批中 2=审批未通过 3=审批通过 4=审批撤销")
    private AuditStatusEnum auditStatus;

    @ApiModelProperty("审批流程实例编号")
    private String auditFlowInstanceId;

    @ApiModelProperty("审批实例类型：1-严选审批 2-物资工匠审批 3-云枢审批")
    private AuditSourceEnum auditFlowInstanceType;

    @ApiModelProperty("审批通过时间")
    private Date auditPassDate;

    @ApiModelProperty(value = "结算类型：1-采购 2-商城 3-混凝土 4-传统租赁 5-专项 6-车辆 7-费用 8-商城租赁 9-货运结算")
    private OrderSettlementTypeEnum settlementType;

    @ApiModelProperty("结算单状态 -100=已作废 10=编制中 20=待确认 30=已拒绝 40=已确认 50=已结算")
    private OrderSettlementStatusEnum status;

    @ApiModelProperty("父结算单系统编号")
    private Long parentSettlementSysNo;

    @ApiModelProperty("作废原因")
    private String invalidReason;

    @ApiModelProperty("提示")
    private String notice;

    @ApiModelProperty("账单到期日")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date billDueDate;

    @ApiModelProperty("结算单明细列表")
    @Valid
    @NotEmpty(message = "结算单明细不能为空")
    private List<OrderSettlementDetailEntity> detailList;
}
